At the C-level, Ruby objects are represented by structures that separate data from behavior through a pointer-based hierarchy. The klass pointer connects an instance to its "associated class" (where methods live), while the super pointer connects classes to their ancestors, creating a structural map that the Ruby VM uses to resolve inheritance.
1. The klass Pointer & Flags
Every Ruby object contains a header with a klass pointer and a bitmask of flags. These flags identify the object's internal state, such as marking automatically created "virtual classes" with a 'V' to handle singleton method assignments.
2. Decoupling State (Figure 24.1)
An instance like lucille stores its own unique instance variables, but it possesses no methods of its own. Its klass pointer directs the VM to the Guitar class object's method table.
3. The Inheritance Chain
When lucille.play() is called, Ruby follows the klass pointer. If the method isn't found in Guitar, it follows the super pointer to Object, granting access to clone or dup.